// src/api/message.js
import axios from 'axios';

const apiClient = axios.create({
    baseURL: '/api/api/v1/message' // 会自动代理到 http://localhost:8088
});

export default {
    getLikeMessages(userId) {
        return apiClient.get('/likes', { params: { userId } });
    },
    getCommentMessages(userId) {
        return apiClient.get('/comments', { params: { userId } });
    },
    // 获取私信会话列表
    getPrivateSessions(userId) {
        return request.get(`/private/sessions?userId=${userId}`);
    },

    // 获取私信详情
    getPrivateMessages(sessionId, userId, page, size) {
        return request.get(`/private/messages?sessionId=${sessionId}&userId=${userId}&page=${page}&size=${size}`);
    },

    // 发送私信
    sendPrivateMessage(senderId, receiverId, content) {
        return request.post('/private/send', {
            receiverId,
            content
        }, {
            params: { userId: senderId }
        });
    },
    deletePrivateMessage(messageId) {
        return apiClient.delete('/private/delete', {
            params: { messageId }
        });
    },
    deletePrivateSession(sessionId, userId) {
        return apiClient.delete(`/private/session/${sessionId}`, {
            params: { userId }
        });
    },
    getFollowMessages(userId) {
        return apiClient.get('/follow-notifications', { params: { userId } });
    },
    getActivityNotifications(userId) {
        return apiClient.get('/activity-notifications', {params: {userId}});
        },
    followBack(followerId, followedId) {
        return apiClient.post('/follow-back', {}, {
            params: {  followedId,followerId,}
        });
    },
    // 添加标记已读和删除消息的API
    markNotificationAsRead(activityId) {
        return request.put(`/notification/read/${activityId}`);
    },

    deleteNotification(activityId) {
        return request.delete(`/notification/delete/${activityId}`);
    }
};
